<html>
<head>
<title><?php print "Calculator"; ?> </title>
</head>

<body bgcolor=white>
<h1><?php print "Calculator"; ?> </h1>

<form action = "calculator.php" method = "post">
<input type = "text" name="input"/>
<input type = "submit" value="Calculate"/>
</form>

<?php

error_reporting(0);

$exp = $_POST["input"];
if (($exp == "0/0") || (preg_match("/[a-zA-Z]/", $exp)==1))
   print "Invalid Expression";
else
{
   $exp .= ";";
   eval('$print = '.$exp);
   print "Result: $print";
}

?>

</body>
</html>